Repository navigation
[google_maps_flutter] Support map UI control options and fix map event bugs - #1213
seungsoo47 wants to merge 9 commits into
Conversation
Implement mapTypeControlEnabled, fullscreenControlEnabled and streetViewControlEnabled (google_maps_flutter_platform_interface 2.16.0, flutter/packages#12191) and webCameraControlEnabled and webCameraControlPosition (platform interface 2.14.0), following google_maps_flutter_web 0.6.3. Previously the three controls were always off and the camera control options were ignored. updateMapConfiguration is overridden because the default implementation serializes the configuration without these options, so changes after the map was created were dropped.
…mageryEnabled Implement the gesture handling and tilt control options added in google_maps_flutter_platform_interface 2.4.0, following google_maps_flutter_web 0.6.4+1 (_configurationAndStyleToGmapsOptions): webGestureHandling sets gestureHandling, falling back to the existing none/auto behavior when unset, and fortyFiveDegreeImageryEnabled sets rotateControl.
… polylines Circles, polygons, and polylines were created without the clickable option, so the JS map made them clickable by default. A shape with consumeTapEvents: false still swallowed taps and GoogleMap.onTap was never called for taps on it. Set clickable from consumeTapEvents, as google_maps_flutter_web does. Upstream: flutter/packages#9838 (7ace630a87d6, google_maps_flutter_web 0.5.13)
GoogleMapsController.init() is called eagerly by buildView and again by GoogleMapsPlugin.init(). The second call skipped map creation but rendered the initial markers, circles, polygons, polylines, ground overlays, and marker clusterers again. The second set replaced the first in the controllers, so the first set stayed on the map for good: removing an initial circle left a copy of it behind. Run the initialization once and let later calls wait for it. google_maps_flutter_web avoids the same problem by leaving GoogleMapsPlugin.init() empty.
The map was reported as ready only on the first `tilesloaded` event, which requires every visible tile to finish downloading. A single stalled or failed tile request left `onMapCreated` pending forever. Also report the map as ready on the first `idle` event once the map div has a non-zero size, as google_maps_flutter_web does. Upstream: flutter/packages#13059 (google_maps_flutter_web 0.6.4+2, flutter/flutter#193452)
…ropped Coordinates sent from the JavaScript side are decoded with json.decode, which yields an int for a whole number such as 3 or -20. The handlers cast them with `as double`, so a tap, long press, marker drag, or cluster tap at such a position threw a cast error that was only logged, and the event was never delivered. The visible region had the same cast. Convert the decoded numbers through `num`, as _convertToLatLng already does.
buildViewWithConfiguration did not pass mapObjects.clusterManagers to GoogleMapsController, so the cluster managers given to the initial GoogleMap were never created: their markers were drawn one by one and onClusterTap never fired. The controller also added the initial markers before the cluster managers, so even a passed-in cluster manager would not have received its initial markers. Pass the cluster managers through and create them before the initial geometry, as google_maps_flutter_web does. Upstream reference: google_maps_flutter_web GoogleMapController (clusterManagers from mapObjects, _initClustering before _renderInitialGeometry).
The cluster click event carries the `id` property of each JS marker,
which is the internal GMarker counter, and _convertCluster turned it
into MarkerId('0'), MarkerId('1') and so on. onClusterTap therefore
reported marker ids that the app never created.
Map the internal ids back to the markers' MarkerIds through
MarkersController, as the marker click and drag handlers already do.
google_maps_flutter_web builds Cluster.markerIds from the MarkerId
stored on each marker (getMarkerId).
A `bounds_changed` event still being handled when the map is disposed calls `getZoom` on a webview that is being torn down, which returns '' instead of a number. The `as num` cast then threw and logged "type 'String' is not a subtype of type 'num'". Return 0.0 for non-numeric results instead of casting.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
JSUYA
left a comment
There was a problem hiding this comment.
It looks that the example is out of sync with the upstream version.
Synchronizing the example should enable testing for some additional features.
| 'mapTypeControl: ${rawOptions['mapTypeControlEnabled'] ?? false}' | ||
| ', fullscreenControl: ${rawOptions['fullscreenControlEnabled'] ?? false}' | ||
| ', streetViewControl: ${rawOptions['streetViewControlEnabled'] ?? false}'; |
There was a problem hiding this comment.
Are these controls actually rendered on the screen and available for testing?
In my local test environment, the option values are being passed to the Maps JS, but I am unable to see the controls themselves rendered on the screen.
Adds support for the remaining web map options and ports several fixes from google_maps_flutter_web.
mapTypeControlEnabled,fullscreenControlEnabled,streetViewControlEnabled,webCameraControlEnabled,webCameraControlPosition,webGestureHandling, andfortyFiveDegreeImageryEnabled.consumeTapEventsfor circles, polygons, and polylines.onMapCreatednever being called when a map tile request stalls or fails. [google_maps_flutter_web] Don't hangonMapCreatedwhen tiles fail to load flutter/packages#13059GoogleMapbeing ignored.Cluster.markerIdsholding internal ids instead of the markers'MarkerIds.getZoomLevelwhile the map is being disposed.